<!--  -->
<template>
  <div class="app-container">
    <el-form :inline="true" size="small">
      <el-form-item label="编号">
        <el-input
          v-model="mId"
          placeholder="请输入账号编号"
          size="small"
        ></el-input>
      </el-form-item>
      <el-form-item label="优惠券名称">
        <el-input
          v-model="mName"
          placeholder="请输入账号名称"
          size="small"
        ></el-input>
      </el-form-item>

      <el-button icon="el-icon-search" type="primary" size="small" @click
        >搜索</el-button
      >
      <el-button icon="el-icon-refresh" size="small" @click>重置</el-button>
      <el-button icon="el-icon-edit" type="warning" size="small" @click
        >新增</el-button
      >
      <el-button icon="el-icon-edit" type="primary" size="small" @click="goMode"
        >商品分类管理</el-button
      >
      <el-button icon="el-icon-edit" type="primary" size="small" @click
        >导入</el-button
      >

      <el-button
        class="ref-btn"
        icon="el-icon-refresh"
        circle
        @click
      ></el-button>
    </el-form>
    <el-table :data="tableData" border stripe>
      <!-- <el-table-column type="selection" width="60" align="center"></el-table-column> -->
      <template v-for="(i, index) in columns">
        <el-table-column
          v-if="index == 5"
          :key="i.id"
          :label="i.label"
          align="center"
          :width="i.width"
        >
          <template slot-scope="scope">
            <el-image src="" fit="fill" :lazy="true"></el-image>
          </template>
        </el-table-column>
        <el-table-column
          v-else
          :prop="i.data"
          :key="i.id"
          :label="i.label"
          align="center"
          :width="i.width"
        />
      </template>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <el-button type="text" icon="el-icon-edit" @click="edit(scope.row)"
            >编辑</el-button
          >
          <el-button
            type="text"
            icon="el-icon-delete"
            style="color: #f66"
            @click="del(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <div class="page">
      <el-pagination
        @size-change="sizeChange"
        @current-change="currentChange"
        :current-page.sync="page"
        :page-sizes="[20, 40, 80, 100]"
        :page-size="limit"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        background
      ></el-pagination>
    </div>

    <!-- 对话框 -->
    <el-dialog
      :title="dialogTitle"
      :visible.sync="showDialog"
      width="50%"
      @close="showDialog = false"
    >
      <el-form v-model="form" label-width="120px" :inline="false" size="normal">
        <el-form-item label="预约时间">
          <el-date-picker
            v-model="form.subTime"
            type="date"
            size="normal"
            placeholder="请选择预约时间"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="门店">
          <el-input
            v-model="form.subShop"
            placeholder="请填写门店"
            style="width: 220px"
          ></el-input>
        </el-form-item>
        <el-form-item label="可预约数量">
          <el-input
            v-model="form.subCount"
            placeholder="请填写可预约数量"
            style="width: 220px"
          ></el-input>
        </el-form-item>
        <el-form-item label="支付方式">
          <el-select
            v-model="form.subPayment"
            placeholder="选择支付方式"
            clearable
            filterable
            style="width: 220px"
            @change
          >
            <el-option
              v-for="(i, index) in options"
              :key="index"
              :label="i.label"
              :value="i.value"
            />
          </el-select>
        </el-form-item>
      </el-form>

      <span slot="footer">
        <el-button @click="showDialog = false">取消</el-button>
        <el-button type="primary" @click>确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getArticle } from "@/api/article";
export default {
  name: "slider",
  data() {
    return {
      mId: "",
      mName: "",
      status: "",
      keyword: "",
      page: 1,
      limit: 11,
      total: 10,
      queryId: "",
      dialogTitle: "创建",
      showDialog: false,
      form: {
        subTime: "",
        subShop: "",
        subCount: "",
        subPayment: "",
      },
      options: [
        {
          value: 1,
          label: "支付方式1",
        },
        {
          value: 2,
          label: "支付方式2",
        },
      ],
      tableData: [
        {
          id: "1",
          name: "2021-02-21",
          price: "生日模板",
          classify: 1,
          type: 1,
          cover: 1,
          count: 20,
        },
        {
          id: "2",
          name: "2021-02-21",
          price: "生日模板",
          classify: 1,
          type: 1,
          cover: 1,
          count: 20,
        },
        {
          id: "3",
          name: "2021-02-21",
          price: "生日模板",
          classify: 1,
          type: 1,
          cover: 1,
          count: 20,
        },
      ],

      columns: [
        { key: 0, label: `商品编号`, data: "id", width: "80" },
        { key: 1, label: `商品名称`, data: "name" },
        { key: 2, label: `商品售价`, data: "price" },
        { key: 3, label: `所属分类`, data: "classify" },
        { key: 4, label: `商品类型`, data: "type" },
        { key: 5, label: `商品海报`, data: "cover" },
        { key: 6, label: `商城库存数量`, data: "count" },
      ],
      artQuery: {
        id: "1",
      },
    };
  },
  created() {
  },
  methods: {
    add() {
      this.form = {
        subTime: "",
        subShop: "",
        subCount: "",
        subPayment: 1,
      };
      this.showDialog = true;
    },
    edit(i) {
      this.form = {
        subTime: i.bTime,
        subShop: i.shop,
        subCount: i.bCount,
        subPayment: i.payment,
      };
      this.showDialog = true;
    },
    del(i, d) {
      this.$confirm("确认删除所选数据？", "确认删除", {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.tableData.splice(i, 1);
        })
        .catch(() => {});
    },
    goMode() {
      this.$router.push("/stock/sMode");
    },
    sizeChange() {},
    currentChange() {},
    
  },
};
</script>
<style scoped>
.slideImg {
  width: 140px;
}
</style>
